attach(mtcars)
? mtcars
#A data frame with 32 observations on 11(numeric) variables.
#[, 1] mpg Miles / (US) gallon
#[, 2] cyl Number of cylinders
#[, 3] disp Displacement(cu.in.)
#[, 4] hp Gross horsepower
#[, 5] drat Rear axle ratio
#[, 6] wt Weight(1000 lbs)
#[, 7] qsec 1 / 4 mile time
#[, 8] vs Engine(0 = V - shaped, 1 = straight)
#[, 9] am Transmission(0 = automatic, 1 = manual)
#[, 10] gear Number of forward gears
#[, 11] carb Number of carburetors
head(mtcars)

# Scatter plot
library(ggplot2)
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()

# Line plot
require(graphics)
? pressure ## something wrong with the data
ggplot(pressure, aes(x = pressure$temprature, y = pressure$pressure)) + geom_line()
#A data frame with 19 observations on 2 variables.
#[, 1] temperature numeric temperature(deg C)
#[, 2] pressure numeric pressure(mm)

# Bar plot
ggplot(data = mtcars, aes(x = mpg)) + geom_histogram(binwidth = 4)

# Box plot
ggplot(ToothGrowth, aes(x = supp, y = len)) + geom_boxplot()

# User-defined Function
mfun <- function(xvar) {
    1/(1+exp(-xvar+10))
}
ggplot(data.frame(x = c(0, 20)), aes(x = x))+stat_function(fun = mfun,geom = "line")